#ifndef _WAITBOX_H
#define _WAITBOX_H

#include <string>
class CWaitBoxDlg : public CDialogImpl<CWaitBoxDlg>
{
	TCHAR prompt[256];
public:
    enum { IDD = IDD_WAITBOX };
 
    BEGIN_MSG_MAP(CWaitBoxDlg)
        MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
        MESSAGE_HANDLER(WM_CLOSE, OnClose)
		MESSAGE_HANDLER(WM_TIMER, OnTimer)
		MESSAGE_HANDLER(WM_SHOWWINDOW, OnShow)
    END_MSG_MAP()
 
    LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
        CenterWindow();
        return TRUE;    // let the system set the focus

    }

	LRESULT OnShow(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
		this->SetDlgItemText( IDC_PROMPT, prompt);
		SetTimer(1, 500);
		return 0;
	}
	LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		static int count=0;
		if(wParam==1){
			std::wstring str = _T("Please Wait ");
			for(int i=0;i<count;i++)
				str.append( _T(". ") );
			count=(++count)%4;
			//CStatic *p=(CStatic *)this->GetDlgItem(IDC_SWAIT);
			//p->SetWindowTextW(s.GetBuffer());
			this->SetDlgItemText( IDC_SWAIT, str.c_str());
		}
		return 0;
	}

    LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
		KillTimer(1);
        EndDialog(IDCANCEL);
        return 0;
    }
	void SetPrompt( LPCTSTR str)
	{
		_tcscpy( prompt, str);
	}
};
#endif